{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pylab as plt\n",
    "import datetime"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Data loading"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "data_raw = pd.read_csv('IVE_tickbidask.txt', header=None, names=['Date','Time','Price','Bid','Ask','Size'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "data = data_raw#.iloc[:100000]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "data['DateTime'] = pd.to_datetime(data['Date'] + ' ' + data['Time'])\n",
    "data = data.drop(columns = ['Date', 'Time'])\n",
    "data = data.set_index('DateTime')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from scipy import stats\n",
    "from bars import *"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                        open   high      low  close  volume\n",
      "DateTime                                                   \n",
      "2009-09-28 09:40:00  50.7900  50.85  50.7100  50.81    9197\n",
      "2009-09-28 09:50:00  50.8100  51.12  50.7833  51.07   26447\n",
      "2009-09-28 10:00:00  51.0988  51.15  51.0800  51.12   53716\n",
      "2009-09-28 10:10:00  51.1500  51.29  51.1500  51.27   47673\n",
      "2009-09-28 10:20:00  51.2800  51.29  51.2100  51.21   30631\n"
     ]
    }
   ],
   "source": [
    "bars = BarSeries(data)\n",
    "time_bars = bars.process_ticks(frequency='10Min')\n",
    "print time_bars.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                     close   high    low   open  volume\n",
      "DateTime                                               \n",
      "2009-09-28 09:47:22  51.06  51.07  50.71  50.79   30044\n",
      "2009-09-28 09:54:38  51.13  51.15  51.06  51.06   28975\n",
      "2009-09-28 10:00:15  51.21  51.21  51.08  51.13   32841\n",
      "2009-09-28 10:05:50  51.21  51.28  51.20  51.21   33764\n",
      "2009-09-28 10:15:13  51.25  51.29  51.19  51.22   37104\n"
     ]
    }
   ],
   "source": [
    "bars = TickBarSeries(data)\n",
    "tick_bars = bars.process_ticks(frequency = 100)\n",
    "print tick_bars.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Fixed horizon"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "metadata": {
    "collapsed": true,
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "WINDOW = 180\n",
    "HORIZON = 60\n",
    "T = 0.025\n",
    "\n",
    "labels = []\n",
    "for i in range(WINDOW, 10000, 1):\n",
    "    window = tick_bars.iloc[i-WINDOW:i]\n",
    "    now = tick_bars.close[i]\n",
    "    future = tick_bars.close[i+HORIZON]\n",
    "    ret = (future - now) / now\n",
    "    \n",
    "    if ret > T:\n",
    "        labels.append(1)\n",
    "    elif ret < -T:\n",
    "        labels.append(-1)\n",
    "    else:\n",
    "        labels.append(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAD8CAYAAAB+UHOxAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAFsxJREFUeJzt3X+QXeV93/H3xyjg2GktCbYqlrAl\nj1W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07sLGNbwWwke9+Jbyo42pjeze9C6p/2FdbzOM1\niD3AZe1uoPOAF9ofOaM/XqO+wj3OH+Af0TsP9hLwDHB7q78VuK2v30XAN+kl+Mf76u+g9x90GvhN\n4JQRjetUYB9wAPgSsLLVJ4HP9vVbSy/V33DM8ncAX6f3i+zXgR8a17iAv9+2/bX2uPW1cLyAnwK+\nDdzf93PWYhyvuf690Dul9KHWfmPb/+l2PN7Rt+zH23KPABeO+N/7QuP6Uvt/MHt89iz0nI5pXP8R\neLBt/07g3X3L/rN2HKeBy8c5rjb974FPHbPcYh+vm+jdxfZter+/tgI/B/xcmx96X5z1aNv+ZN+y\nIz1evhNYkjqqC6eAJElzMAAkqaMMAEnqKANAkjrKAJCkjjIAJKmjDABJ6igDQJI66v8Db1mxargo\nR3IAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure()\n",
    "plt.hist(labels, bins = 5, alpha = 0.7)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Volatility horizon"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "metadata": {
    "collapsed": true,
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "labels = []\n",
    "for i in range(WINDOW, 10000, 1):\n",
    "    window = tick_bars.iloc[i-WINDOW:i]\n",
    "    now = tick_bars.close[i]\n",
    "    future = tick_bars.close[i+HORIZON]\n",
    "    ret = (future - now) / now\n",
    "    \n",
    "    window_abs_returns = np.abs(window.close.pct_change())\n",
    "    Ti = np.std(window_abs_returns) + np.mean(window_abs_returns)\n",
    "    \n",
    "    if ret > Ti:\n",
    "        labels.append(1)\n",
    "    elif ret < -Ti:\n",
    "        labels.append(-1)\n",
    "    else:\n",
    "        labels.append(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png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OrZa0d3HP+1qKA60ryeNJjq+qx9oL1u4X2NQ7gC9V\n1Y+Htj39bnhfkn8C/nSSdVXVrvb74SS3AScDX2SRxyvJK4H/YBD+tw9t+4DHawZzfl3JUJ+dSZYA\nr2Lw9zTKugtZF0nexiBU31xV+6bbZ3lOx/GCNsrXuzwxNPs5Btd8ptd9y37r3jaGmkaqa8h64KLh\nhgUcr1HMVvvYx6uHU0Azfv1EDa6q3Mrg/DvABmBcRxRb2/ZG2e7zzj22F8Hp8+7nAzPeLbAQdSVZ\nOn0KJcmxwJuA+xd7vNpz9yUG50av32/ZOMdrlK8rGa73AuCWNj5bgfUZ3CW0ClgN3HkQtcyrriQn\nA/8InFdVu4faZ3xOJ1jX8UOz5wEPtOmbgDNbfUuBM/npI+EFravV9joGF1S/PtS2kOM1iq3Ae9rd\nQKcBT7c3OeMfr3Ff4Z7kD/BbDM6D7QMeB25q7a8Gbhzqdy7wHQYJ/pGh9hMZ/AOdAv4VOGJMdR0D\n3AzsAL4KHN3a1wKfG+q3kkGqv2y/9W8BvsXgheyfgVdMqi7gV9u+v9l+bzwUxgt4F/Bj4J6hn5MW\nYrxm+nthcErpvDZ9ZHv8U208Thxa9yNtvQeBc8b89z5XXV9t/w6mx2frXM/phOr6K+C+tv9bgdcN\nrft7bRyngPdOsq42/xfAJ/Zbb6HH62oGd7H9mMHr10bg/cD72/Iw+I+zHmr7Xzu07ljHy08CS1Kn\nejgFJEmagQEgSZ0yACSpUwaAJHXKAJCkThkAktQpA0CSOmUASFKn/h+d1nD8qVgioQAAAABJRU5E\nrkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure()\n",
    "plt.hist(labels, bins = 5, alpha = 0.7)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Meta labeling"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 167,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def get_meta_barier(future_window, last_close, min_ret, tp, sl, vertical_zero = False):\n",
    "    '''\n",
    "        XXX\n",
    "    '''\n",
    "    if vertical_zero:\n",
    "        min_ret_situation = [0, 0, 0]\n",
    "    else:\n",
    "        min_ret_situation = [0, 0]\n",
    "        \n",
    "        \n",
    "    differences = np.array([(fc - last_close) / last_close for fc in future_window])\n",
    "    \n",
    "    # Are there gonna be fluctuations within min_ret???\n",
    "    min_ret_ups = np.where((differences >= min_ret) == True)[0]\n",
    "    min_ret_downs = np.where((differences < -min_ret) == True)[0]\n",
    "  \n",
    "    if (len(min_ret_ups) == 0) and (len(min_ret_downs) == 0):\n",
    "        if vertical_zero:\n",
    "            min_ret_situation[2] = 1\n",
    "        else:\n",
    "            if differences[-1] > 0:\n",
    "                min_ret_situation[0] = 1\n",
    "            else:\n",
    "                min_ret_situation[1] = 1            \n",
    "    else:\n",
    "        if len(min_ret_ups) == 0: min_ret_ups = [np.inf]\n",
    "        if len(min_ret_downs) == 0: min_ret_downs = [np.inf]\n",
    "        if min_ret_ups[0] > min_ret_downs[0]:\n",
    "            min_ret_situation[0] = 1\n",
    "        else:\n",
    "            min_ret_situation[1] = 1\n",
    "        \n",
    "    #  Take profit and stop losses indices\n",
    "    take_profit = np.where((differences >= tp) == True)[0]\n",
    "    stop_loss = np.where((differences < sl) == True)[0]\n",
    "    \n",
    "    # Fluctuation directions coincide with take profit / stop loss actions?\n",
    "    if min_ret_situation[0] == 1 and len(take_profit) != 0:\n",
    "        take_action = 1\n",
    "    elif min_ret_situation[1] == 1 and len(stop_loss) != 0:\n",
    "        take_action = 1\n",
    "    else:\n",
    "        take_action = 0.\n",
    "    \n",
    "    return min_ret_situation, take_action"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 202,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "WINDOW = 180\n",
    "HORIZON = 60\n",
    "\n",
    "TIs = []\n",
    "# MIN_RET = 0.01\n",
    "TP = 0.015\n",
    "SL = -0.015\n",
    "\n",
    "X, Y, Y2 = [], [], []\n",
    "for i in range(WINDOW, 10000, 1):\n",
    "    window = tick_bars.iloc[i-WINDOW:i]\n",
    "    now = tick_bars.close[i]\n",
    "    future_window = tick_bars.close[i:i+HORIZON]\n",
    "    \n",
    "    window_abs_returns = np.abs(window.close.pct_change())\n",
    "    Ti = np.std(window_abs_returns) + np.mean(window_abs_returns)\n",
    "    \n",
    "    min_ret_situation, take_action = get_meta_barier(future_window, now, Ti, TP, SL, True)\n",
    "    X.append(window.close)\n",
    "    Y.append(min_ret_situation)\n",
    "    Y2.append(take_action)\n",
    "    TIs.append(Ti)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 203,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAD8CAYAAAB+UHOxAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAFIhJREFUeJzt3X+s3fV93/HnKzgkTZphA7cWs52Z\nKW47kimE3QJRpi6NW2NYFSMtQUTrcJA1Tx3r2q7aRrY/vEGQEm0rK1JD69VeTNSGUNoMq2VlliGK\nNg3CJVAaoIwbCMEe4Fts3LUoaU3f++N8TG/ce3vPtc89N7ef50O6Op/v+/v5fr+fDzZ+3e+Pc06q\nCklSf9603AOQJC0PA0CSOmUASFKnDABJ6pQBIEmdMgAkqVMGgCR1ygCQpE4ZAJLUqVXLPYC/zPnn\nn18bN25c7mFI0oryyCOP/EFVTSzU77s6ADZu3MjU1NRyD0OSVpQkzw/Tz0tAktQpA0CSOjVUACT5\n2SRPJPlaks8neWuSC5M8lGQ6yReSnN36vqUtT7f1G2ft5xOt/nSSK5ZmSpKkYSwYAEnWAf8cmKyq\n9wBnAdc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2\nT5LzGVwSenacgxyxYeb8TWAzQJK/xSAAZsY6yvHaD1zXnga6HDheVS+Oaucr+hJQzfPREkluAqaq\naj+wh8Fp4jSDmy3XLt+Iz9yQc/4PwPcCv97ud3+zqj68bIM+Q0PO+a+UIed8H7AlyZPA68C/rKoV\ne3Y75Jx/DvgvSX6WwQ3hj6/kX+iSfJ5BiJ/f7mvsAt4MUFW/xOA+x1XANPAacP1Ij7+C/9tJks7A\nSr8EJEk6TQaAJHXKAJCkThkAktQpA0CSOmUASFKnDABJ6pQBIEmd+v9RBDCRMJj79QAAAABJRU5E\nrkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure()\n",
    "plt.hist(Y2, bins = 5, alpha = 0.7)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 204,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAD8CAYAAAB+UHOxAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAEddJREFUeJzt3X2sZHV9x/H3R1axPhQWWSnZpS7G\nTQ0kVekK+JBWpYUFq0tTNRiri12ztYVG06at1KS0KK3+U6xptSGycTGWh6IWarC6BYxpDQ8XRRAQ\nuaIUNsiu7IISIy302z/mt3RY93Jn2Jm54O/9SiZzzvf8zpzvOXf2fu6ZMzObqkKS1J+nLXUDkqSl\nYQBIUqcMAEnqlAEgSZ0yACSpUwaAJHXKAJCkThkAktQpA0CSOrVsqRt4PAcffHCtXr16qduQpKeU\n66+//gdVtWKxcU/qAFi9ejVzc3NL3YYkPaUkuXOUcb4EJEmdMgAkqVMGgCR1aqQASPK9JDcluSHJ\nX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HB25x5jTeOxF4Ivb\n9JE89iLwHUzuIvAofb2MwUWvNXvUlwP7t+mDgduZ0MWwEfs6dGj6t4Cr6/8vOH239be8TR80q77a\nuBczuCCXWRyvoW2sZuGLmq/nsRforp328Rqxr19kcF3rlXvUnw08d2j6qwy+lHFWff3C7p8fg1+k\n/9WO3UjPgWn11ZYfwOA6wbNndbzavp8PfORxxszkOTaxAz3LG4Mr5N9m8Mv0/a12FoO/qgGeCfxz\n+8dwLfDCoXXf39a7DThxxn39O3AvcEO7XdbqrwRuav8AbgI2zrivvwFubtu/Cnjx0Lq/247jPPDO\nWfbV5v8S+NAe6037eF0A3AP8D4PXWDcC7wbe3ZaHwX9s9J22/bUzOl6L9fUJYNfQ82uu1V/YjtU3\n2s/5/TPu6/Sh59fVDAXU3p4Ds+qrjTmVwRtDhteb9vF6NYNrDDcO/axOWornmJ8ElqROPRWvAUiS\nJsAAkKROGQCS1CkDQJI6ZQBIUqcMAEnqlAEgSZ0yACSpU/8HIlnpnilC+Y8AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure()\n",
    "plt.hist([np.argmax(y) for y in Y], bins = 5, alpha = 0.7)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.14"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
